package stephencarmody.fonttexture;

import java.util.HashSet;
import java.util.Set;

import javax.imageio.ImageIO;
import javax.swing.JFileChooser;

public final class ImageSaveDialog extends JFileChooser {
    
    private static final long serialVersionUID = 0;
    
    public ImageSaveDialog() {
    	registerFilters();
    	setAcceptAllFileFilterUsed(false);
    }

    /**
     * Registers all available, unique, image writer format names
     * as filename extension filters.
     */
    private void registerFilters() {
    	String[] formatNames = ImageIO.getWriterFormatNames();
        Set<String> set = new HashSet<String>();
        for ( String formatName : formatNames ) {
            set.add(formatName.toLowerCase());
        }
        for ( String formatName : set ) {
        	addChoosableFileFilter(new ImageFilter(formatName));
        }
    }
}
    